package com.htjx.mall.commons.api;

import java.io.Serializable;

/**
 * 接口请求结果：0表示请求正常、非0并表示请求出错
 * 
 * @author jingrenlang
 * 
 */
public class Result implements Serializable {
	private static final long serialVersionUID = 1L; 
	
	private int code;

	private String msg;

	private Object body;

	public Result(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getBody() {
		return body;
	}

	public void setBody(Object body) {
		this.body = body;
	}

	@SuppressWarnings("unchecked")
	public <T> T getBody(Class<T> clazz) {
		//JSONObject obj = (JSONObject) this.body;
		//return JSON.parseObject(obj.toJSONString(), clazz);
		return (T) body;
	}
}
